package temp.lho.lws.service.impl;

import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import temp.lho.lws.mapper.FlowinfomationMapper;
import temp.lho.lws.pojo.Flowinfomation;
import temp.lho.lws.service.UtilService;
import temp.lho.lws.vo.LoginVo;

@Service("utilService")
public class UtilServiceImpl implements UtilService {

    @Autowired
    private FlowinfomationMapper flowinMapper;

    //流程
    //1.张三坐席报案，向工作流程表插入一条报案信息
    public Integer FlowInfomation1(Flowinfomation flowInf){
        flowInf.setTaskid(1); //设置节点ID
        flowInf.setTaskpid(0); //设置流程父ID
        flowInf.setTaskname("报案"); //设置流程名称
        flowInf.setFlowid("FLOW01"); //设置流程名称

        //赔案号，处理人ID，处理人姓名从前台获取

        flowInf.setCreatetime("now()"); //设置创建时间
        flowInf.setTransmitstate(1);   //流转状态（1.正常流转 2.退回流转 3.上报流转）
        flowInf.setJobstate(4);        //任务状态(1:待处理 2:接收 3:暂存 4:已处理 5:退回 )
        flowInf.setFlowstate("N");     //流程状态(N:未完成  Y:完成  F:流程作废)
        return flowinMapper.addNextFlow(flowInf);
    }
    //2.向工作流程表插入一条调度信息
    public Integer FlowInfomation2(Flowinfomation flowInf){
        flowInf.setTaskid(2); //设置节点ID
        flowInf.setTaskpid(1); //设置流程父ID
        flowInf.setTaskname("调度"); //设置流程名称
        flowInf.setFlowid("FLOW01"); //设置流程名称

        //赔案号，处理人ID，处理人姓名从前台获取

        flowInf.setCreatetime("now()"); //设置创建时间
        flowInf.setTransmitstate(1);   //流转状态（1.正常流转 2.退回流转 3.上报流转）
        flowInf.setJobstate(1);        //任务状态(1:待处理 2:接收 3:暂存 4:已处理 5:退回 )
        flowInf.setFlowstate("N");     //流程状态(N:未完成  Y:完成  F:流程作废)
        return flowinMapper.addNextFlow(flowInf);
    }

    //3.当李四点击代办任务的派工按钮时，需要更新调度任务的接收时间为系统时间，任务状态为2
    public Integer FlowInfomation3(Integer taskid, Integer jobstate,Integer transmitstate, LoginVo user){
        return flowinMapper.updateJobStatus(taskid,jobstate,transmitstate,user);
    }

    //4.派工给王五，新增一条查勘定损信息
    public Integer FlowInfomation4(Flowinfomation flowInf){
        flowInf.setTaskid(3); //设置节点ID
        flowInf.setTaskpid(2); //设置流程父ID
        flowInf.setTaskname("查勘定损"); //设置流程名称
        flowInf.setFlowid("FLOW01"); //设置流程名称

        //赔案号，处理人ID，处理人姓名从前台获取

        flowInf.setCreatetime("now()"); //设置创建时间
        flowInf.setTransmitstate(1);   //流转状态（1.正常流转 2.退回流转 3.上报流转）
        flowInf.setJobstate(2);        //任务状态(1:待处理 2:接收 3:暂存 4:已处理 5:退回 )
        flowInf.setFlowstate("N");     //流程状态(N:未完成  Y:完成  F:流程作废)
        return flowinMapper.addNextFlow(flowInf);
    }

    //5.当王五点击代办任务的查勘定损按钮时，需要更新查勘定损任务的接收时间为系统时间，任务状态为2
    public Integer FlowInfomation5(Integer taskid, Integer jobstate,Integer transmitstate, LoginVo user){
        return flowinMapper.updateJobStatus(taskid,jobstate,transmitstate,user);
    }

    //6.王五开始查勘信息录入，点击暂存按钮,需要更新查勘定损任务的任务状态为3
    public Integer FlowInfomation6(Integer taskid, Integer jobstate,Integer transmitstate, LoginVo user){
        return flowinMapper.updateJobStatus(taskid,jobstate,transmitstate,user);
    }
    //7.王五开始查勘信息录入，点击提交按钮,插入一条核损信息
    public Integer FlowInfomation7(Flowinfomation flowInf){
        flowInf.setTaskid(4); //设置节点ID
        flowInf.setTaskpid(3); //设置流程父ID
        flowInf.setTaskname("核损"); //设置流程名称
        flowInf.setFlowid("FLOW01"); //设置流程名称

        //赔案号，处理人ID，处理人姓名从前台获取

        flowInf.setCreatetime("now()"); //设置创建时间
        flowInf.setTransmitstate(1);   //流转状态（1.正常流转 2.退回流转 3.上报流转）
        flowInf.setJobstate(1);        //任务状态(1:待处理 2:接收 3:暂存 4:已处理 5:退回 )
        flowInf.setFlowstate("N");     //流程状态(N:未完成  Y:完成  F:流程作废)
        return flowinMapper.addNextFlow(flowInf);
    }
    //8.当麻六点击代办任务的核损按钮时，需要更新核损任务的接收时间为系统时间，任务状态为2
    public Integer FlowInfomation8(Integer taskid, Integer jobstate,Integer transmitstate, LoginVo user){
        return flowinMapper.updateJobStatus(taskid,jobstate,transmitstate,user);
    }
    //9.麻六审核查勘信息，发现查勘资料录入不全，点击退回按钮，退回查勘定损
    public Integer FlowInfomation9(Flowinfomation flowInf){
        return FlowInfomation4(flowInf);
    }
    //10.麻六开始录入审核意见信息，点击提交按钮，插入一条理算信息
    public Integer FlowInfomation10(Flowinfomation flowInf){
        flowInf.setTaskid(5); //设置节点ID
        flowInf.setTaskpid(4); //设置流程父ID
        flowInf.setTaskname("理算"); //设置流程名称
        flowInf.setFlowid("FLOW01"); //设置流程名称

        //赔案号，处理人ID，处理人姓名从前台获取

        flowInf.setCreatetime("now()"); //设置创建时间
        flowInf.setTransmitstate(1);   //流转状态（1.正常流转 2.退回流转 3.上报流转）
        flowInf.setJobstate(1);        //任务状态(1:待处理 2:接收 3:暂存 4:已处理 5:退回 )
        flowInf.setFlowstate("N");     //流程状态(N:未完成  Y:完成  F:流程作废)
        return flowinMapper.addNextFlow(flowInf);
    }
    //11.赵七开始理算，如果撤销，则返回核损
    public Integer FlowInfomation11(Flowinfomation flowInf){
        return FlowInfomation7(flowInf);
    }
    //12.插入一条核赔信息
    public Integer FlowInfomation12(Flowinfomation flowInf){
        flowInf.setTaskid(6); //设置节点ID
        flowInf.setTaskpid(5); //设置流程父ID
        flowInf.setTaskname("理算"); //设置流程名称
        flowInf.setFlowid("FLOW01"); //设置流程名称

        //赔案号，处理人ID，处理人姓名从前台获取

        flowInf.setCreatetime("now()"); //设置创建时间
        flowInf.setTransmitstate(1);   //流转状态（1.正常流转 2.退回流转 3.上报流转）
        flowInf.setJobstate(1);        //任务状态(1:待处理 2:接收 3:暂存 4:已处理 5:退回 )
        flowInf.setFlowstate("N");     //流程状态(N:未完成  Y:完成  F:流程作废)
        return flowinMapper.addNextFlow(flowInf);
    }
    //13.插入一条结案信息
    public Integer FlowInfomation13(Flowinfomation flowInf){
        flowInf.setTaskid(7); //设置节点ID
        flowInf.setTaskpid(6); //设置流程父ID
        flowInf.setTaskname("结案"); //设置流程名称
        flowInf.setFlowid("FLOW01"); //设置流程名称

        //赔案号，处理人ID，处理人姓名从前台获取

        flowInf.setCreatetime("now()"); //设置创建时间
        flowInf.setTransmitstate(1);   //流转状态（1.正常流转 2.退回流转 3.上报流转）
        flowInf.setJobstate(1);        //任务状态(1:待处理 2:接收 3:暂存 4:已处理 5:退回 )
        flowInf.setFlowstate("N");     //流程状态(N:未完成  Y:完成  F:流程作废)
        return flowinMapper.addNextFlow(flowInf);
    }
}
